@extends('backend.template.bootstrap')
@section('content')
<div class="m-b-md">
	<h3 class="m-b-none">小说管理（{{ $books->total() }}）</h3>
</div>
<div class="row">
	<div class="col-lg-12">
		<ul class="breadcrumb">
			<li><a href="{{ url('backend') }}"><i class="fa fa-home"></i> 首页</a></li>
			<li class="active">小说管理</li>
		</ul>
	</div>
</div>
<div class="panel panel-default">
	<div class="panel-body">
		{!! Form::open(array('url' => '/backend/books', 'class' => 'form-inline', 'method' => 'get')) !!}
			&nbsp;&nbsp;
			<div class="form-group">
			 	{!! Form::select('category_id', $categories, Input::get('category_id'), array('class' => 'form-control', 'placeholder' => '分类')) !!}
			</div>
			<div class="form-group">
			 	{!! Form::text('name', Input::get('name'), array('class' => 'form-control', 'placeholder' => '名称')) !!}
			</div>
			<div class="form-group">
				{!! Form::text('author', Input::get('author'), array('class' => 'form-control', 'placeholder' => '作者')) !!}
			</div>
			<button type="submit" class="btn btn-primary">立即查找</button>
			<a class="btn btn-info" href="{{ url('/backend/books') }}">重置</a>
		{!! Form::close() !!}
		<br />
		<table class="table table-striped b-t b-light table-middle">
			<thead>
				<tr>
					<th colspan="2" class="text-center">小说信息</th>
					<th>简介</th>
					<th class="text-center">状态</th>
					<th width="250" class="text-center">OP</th>
				</tr>
			</thead>
			<tbody>
				@foreach($books as $book)
				<tr>
					
					<td width="120">
						<label for="{{ $book->id }}">
							<img alt="" src="{{ $book->thumbnailUrl() }}" width="99" height="124" >
						</label>
					</td>
					<td width="280">
						<small>
							名称：{{ $book->name }} <br />
							分类：
							[ {{ $book->category->name }} ]
							<br />
							作者：{{ $book->author }}
							<br />
							封面：{{ $book->thumbnail }}
							<br />
							地址：{{ $book->href }}
						</small>
					</td>
					<td>
						{!! str_limit($book->abstract, 400) !!}
					</td>
					<td width="80">
						{{ $book->status }}
					</td>
					<td>
						<a class="btn btn-sm btn-default" href="{{ route('books.sections.index', array($book->id)) }}">查看章节</a>
						<a class="btn btn-sm btn-primary" href="{{ route('books.edit', array($book->id)) }}">编辑</a>
						{!! Form::open(array('method' => 'DELETE', 'route' => array('books.destroy', $book->id), 'class' => 'inline')) !!}
							<a class="btn btn-sm btn-danger" href="#" onclick="if(confirm('确定删除吗？')){$(this).parent('form').submit();}">删除</a>
						{!! Form::close() !!} 
					</td>
				</tr>
				@endforeach
			</tbody>
		</table>
		<div class="text-center">
			{!! $books->render() !!}
		</div>
	</div>
</div>
@endsection